TreeGrid Filter Tutorial
2. Filtering rows in tree
Various ways to filter rows in parent / child relation
-
There are two special attributes for filtering in tree Cfg
StandardFilter
and row CanFilter
.
For all other information about filtering see previous example 01 - Filtering rows.html.
-
Hide all not found
By default is set Cfg attribute StandardFilter='0' and all row attributes CanFilter='1'.
It tests parent rows before their children. If the parent row does not fulfill the filter condition, it is hidden and its children are not tested at all.
It is the fastest method. It cannot be used with OnRowFilter API event, when this event filters parents according to their children.
Use it when some rows, especially leaf rows without children, cannot be hidden by filter (have set CanFilter='0').
-
Hide all not found, iterate all
When set Cfg attribute StandardFilter='1', it tests row children before the row itself.
It also hides all rows that do not pass the filter like previous option, but there can be used OnRowFilter API event if it filters rows according to their children.
Use it with OnRowFilter code based on row children.
-
Show all found
It shows all rows that fulfill the filter condition. If any parent contains some visible child, it is shown too.
It is set by Cfg attribute StandardFilter='2'.
It tests children before parents, so it also supports OnRowFilter in all cases.
Use it when all rows can be hidden by filter, to show all the found rows.
-
Show all found, with all children
It shows all rows that fulfill the filter condition. It always shows all children of found parents.
It is set by Cfg attribute StandardFilter='3'.
It tests parent rows before their children. It tests children of parent that does not fulfill the filter condition.
Use it when all rows can be hidden by filter, to show all the found rows with children.
Show all found, hide empty parents
It shows all rows that fulfill the filter condition. Parent rows are visible only if they contain some visible children.
It is set by Cfg attribute StandardFilter='2' and row CanFilter='2' or '3'.
The CanFilter='2' / '3' should not be set to the rows without children, otherwise they will be always hidden.
If the row has set CanFilter='2' or '3', it is hidden if it does not have any visible children, regardless it fulfills the filter condition.
If set CanFilter='2' the row is not tested for the filter condition and it visible or hidden only by its children.
Use it show all found rows, but hide all unused groups.